<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function fn(a) {
            for (var i = 0; i <= a; i++) {
                document.write("<br>")
                for (var j = 0; j <= a - i; j++) {
                    document.write("&nbsp");
                }
                for (j = 0; j <= 2*i; j++) {
                    document.write("*");
                }
            }
        }

        var a = prompt("请输入几行*", "9")
        fn(a);
    </script>
</head>

<body>

</body>

</html>